{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "乐学偶得版权所有  公众号：乐学Fintech  主讲人：William LX_LAB教研团队提供技术支持 正版视频： 网易云课堂：乐学偶得"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "16.写一个程序，这个程序能够将给定列表中的所有元素进行遍历，并且进行判断每一个元素是否为偶数/奇数，如果为偶数/奇数，则将所有的偶数打印出来；但是，如果看到了888这个数字，则停止运行"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "tips:注意奇偶判断的常见方法，停止运行用什么？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[888, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "number_list=[888,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]\n",
    "number_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "888\n"
     ]
    }
   ],
   "source": [
    "for elem in number_list:\n",
    "    if elem == 888:\n",
    "        print(elem)\n",
    "        break\n",
    "    elif elem % 2 ==0:\n",
    "        print(elem)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "number_list=[1,2,3,4,5,6,7,8,9,10,11,12,888,13,14,15,16,17,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "4\n",
      "6\n",
      "8\n",
      "10\n",
      "12\n",
      "888\n"
     ]
    }
   ],
   "source": [
    "for elem in number_list:\n",
    "    if elem == 888:\n",
    "        print(elem)\n",
    "        break\n",
    "    elif elem % 2 ==0:\n",
    "        print(elem)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "11\n",
      "888\n"
     ]
    }
   ],
   "source": [
    "for elem in number_list:\n",
    "    if elem == 888:\n",
    "        print(elem)\n",
    "        break\n",
    "    elif elem % 2 !=0:\n",
    "        print(elem)\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
